package huawei;

import java.util.*;

public class Main2 {
    List<List<Integer>> res = new ArrayList<>();

    public void x(){
        Scanner in = new Scanner(System.in);
        int node = in.nextInt();
        HashMap<Integer, List<Integer>> map = new HashMap<>();
        for(int i = 0;i<node;i++){
            map.put(i,new ArrayList<>());
        }

        int edge = in.nextInt();
        for(int i = 0;i<edge;i++){
            int root = in.nextInt();
            int sun = in.nextInt();
            List<Integer> list = map.get(root);
            list.add(sun);
            map.put(root,list);
        }

        int block = in.nextInt();
        HashSet<Integer> blockSet = new HashSet<>();
        for(int i = 0;i<block;i++){
            blockSet.add(in.nextInt());
        }
        if(blockSet.contains(0)) {
            System.out.println("NULL");
            return;
        }

        // 深度优先搜索
        ArrayList<Integer> path = new ArrayList<>();
        path.add(0);
        dfs(0,map,blockSet,path);
    }

    public static void main(String[] args) {
        Main2 main2 = new Main2();
        main2.x();

        main2.res.sort(new Comparator<List<Integer>>() {
            @Override
            public int compare(List<Integer> o1, List<Integer> o2) {
                return o1.size()-o2.size();
            }
        });
        if(main2.res.size() == 0) System.out.println("NULL");
        else {
            for(int i = 0;i<main2.res.get(0).size();i++){
                if(i!=0) System.out.print("->");

                System.out.print(i);
            }
        }
    }

    public void dfs(int root, HashMap<Integer, List<Integer>> map, HashSet<Integer> blockSet,ArrayList<Integer> path) {
        List<Integer> sonlist = map.get(root);
        if(sonlist.size() == 0){
            this.res.add(path);
            return;
        }

        for (Integer integer : sonlist) {
            if(!blockSet.contains(integer)){
                ArrayList<Integer> newPath = new ArrayList<>(path);
                newPath.add(integer);
                dfs(integer,map,blockSet,newPath);
            }
        }
    }


}
